using System.Collections;

namespace CSharpPro._1023;

public class Demo
{
    
    //冒泡法
    public void Test()
    {
        int n;
        Console.Write("Enter a number: ");
        Console.WriteLine();
        n = Convert.ToInt32(Console.ReadLine());
        int[] a= new int[n];
        for (int i = 0; i < n; i++)
        {
            
            a[i]=Convert.ToInt32(Console.ReadLine());
        }

        for (int i = 0; i < n-1; i++)
        {
            for (int j = 0; j < n - 1 - i; j++)
            {
                if (a[j] > a[j + 1])
                {
                    int temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
                }
                
            }
            
            
            
            
        }

        for (int i = 0; i < n; i++)
        {
            Console.Write(a[i]+" ");
        }
        
    }
    
    
    
    
    
    
    
    
    public void TestPrint()
    {
        int[] arr = new int[5];
        arr[0] = 1;
        arr[1] = 2;
        arr[2] = 3;
        for (int i = 2; i < arr.Length; i++)
        {
            Console.WriteLine(arr[i]+"\t");
        }
        string [] arr2 = new string[5];
        arr2[0] ="hello";
        arr2[4] = "world";
        for (int i = 0; i < arr2.Length; i++)
        {
            Console.WriteLine(arr2[i]+"\t");
        }
        int[,] arr3 = new int[3,3];
        arr3[0,0] = 1;
        arr3[1,1] = 2;
        arr3[2,2] = 3;
        int[,] arr4 =
        {
            { 1, 2, 3 },
            {4, 5, 6},
            { 7, 8, 9 }
        };
        int[] arr5 = { 2, 56, 34, 89, 111 };
        Array.Sort(arr5);
        Console.WriteLine();
        foreach (int i in arr5)
        {
            Console.WriteLine(i);
        }
        ArrayList list = new ArrayList();
        list.Add(1);
        list.Add(2);
        list.Add(3);
        list.Add("hello");
        list.Add("world");
        Console.WriteLine(list.Count);
        Console.WriteLine(list.Capacity);
        foreach (Object i in list)
        {
            Console.WriteLine(i+"\t");
        }
       
    }
}